package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/6/7.
 * 可提现佣金明细 查询 接口
 */
@HttpInlet(Conn.INLET_API_COMMISSION_EXTRACT)
public class GetApiCommissionExtract extends BaseAsyGet<GetApiCommissionExtract.Info> {
    public String userid, starttime, endtime;

    public GetApiCommissionExtract(AsyCallBack<GetApiCommissionExtract.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");


        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();
            info.commission = jsonObject.optDouble("commission");

            JSONArray array = jsonObject.optJSONArray("data");
            for (int i = 0; i < array.length(); i++) {

                JSONObject o = array.optJSONObject(i);
                Data d = new Data();

                d.id = o.optString("id");
                d.price = o.optString("price");
                d.client = o.optString("client");
                d.products = o.optString("products");
                d.total = o.optString("total");
                d.ordersn = o.optString("ordersn");
                d.settime = o.optString("settime");

                info.dataList.add(d);
            }
            return info;
        }


        return null;
    }

    public static class Info {

        public Double commission;
        public List<Data> dataList = new ArrayList<>();
    }

    public static class Data {

        //        "id": "2",
//                "price": "100.00",
//                "client": "张某某",
//                "products": "人身意外险"
//        "ordersn": "a201608295049535348",
//                "settime": "1472706913",
//                "total": "5000.00"
        public String id, price, client, products, total, ordersn, settime;
    }
}
